package com.hoongs.v1.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.hoongs.v1.utils.DateUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import org.hibernate.validator.constraints.Length;
import org.springframework.stereotype.Repository;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Repository
@TableName(value = "user")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(value = {"password"})
public class User implements Serializable {

    private static final long serialVersionUID = -40356785423868312L;

    @TableId(type = IdType.ASSIGN_UUID)
    private String id;
    private String role = "1";

    @NotBlank(message = "请输入用户账号")
    @Length(message = "账号不能超过个 {max} 字符", max = 20)
    private String username;

    @NotBlank(message = "请输入用户密码")
    private String password;
    private String avater;
    private String summary;
    private String status = "1";

    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;       // 发布时间

    @JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;    // 更新时间

}
